function Overloadable() {
    this.do = function(){
        return "没找到对应重载";
    };
}
Overloadable.prototype.addMethod = function(fn) {
    var oldMethod = this.do;
    this.do = function() {
        if (arguments.length === fn.length) {
            return fn.apply(this, arguments);
        } else {
            return oldMethod.apply(this, arguments);
        }
    };
};

var method = new Overloadable();
method.addMethod(function(a) {
    return a;
});
method.addMethod(function(a, b) {
    return a + b;
});
method.addMethod(function(a, b, c) {
    return a + b + c;
});

console.log(method.do(1));
console.log(method.do(1, 2));
console.log(method.do(1, 2, 3));
console.log(method.do(1,2,3,4));